package 内部类;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class winTest {
    public static void main(String[] args) {

        JFrame win = new JFrame("登录界面");
        JPanel panel = new JPanel();
        win.add(panel);

        JButton but = new JButton("登录");
        win.add(but);

//        but.addActionListener(new ActionListener() {
//            @Override
//            public void actionPerformed(ActionEvent e) {
//                JOptionPane.showConfirmDialog(win,"登录一下");
//            }
//        });

        but.addActionListener(e -> JOptionPane.showConfirmDialog(win,"登录一下"));

        win.setSize(400,400);
        win.setLocationRelativeTo(null);
        win.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        win.setVisible(true);
    }
}

